package com.example.jsruntimedemo.js;

import android.util.Log;

import com.eclipsesource.v8.V8;
import com.example.jsruntimedemo.js.JsBundle;

public class JsContext {
    private static final String TAG = "JsContext";
    private V8 mEngine;

    public JsContext() {
        init();
    }

    private void init() {
        mEngine = V8.createV8Runtime();
    }

    public V8 getEngine() {
        return mEngine;
    }

    public void runApplication(JsBundle jsBundle) {
        try {
            mEngine.executeVoidScript(jsBundle.getAppJavaScript());
        } catch (Exception e) {
            e.printStackTrace();
            Log.e(TAG, "runApplication: ", e);
        }

    }
}
